# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

#学号、姓名、年龄、性别、年纪
info = [
	{"no": 1, "name": "张三", "age": 18, "sex": 1,"greed": "二年级"}
]

def main():
	print("-----------学生管理系统-----------")
	print("请选择功能：")
	print("1、添加学员")
	print("2、删除学员")
	print("3、修改学员")
	print("4、查询学员")
	print("5、显示所有学员")
	print("6、退出系统")
	print("-" * 30)

def add_student():
	'''新增学员'''
	global info
	student = {}
	no = int(input("请输入学号："))
	for item in info:
		if item["no"] == no:
			print("您输入的学号已存在，请重新输入")
			add_student()
	name = input("请输入姓名：")
	age = input("请输入年龄：")
	sex = int(input("请输入性别："))
	greed = input("请输入年纪：")
	student["no"] = no
	student["name"] = name
	student["age"] = age
	student["sex"] = sex
	student["greed"] = greed
	info.append(student)
	print("新增学员{0}成功".format(name))

def delete_student():
	'''删除学员'''
	global info
	no = int(input("请输入要删除的学生学号："))
	for item in info:
		if item["no"] == no:
			info.remove(item)
			break
		else:
			print("输入的学生学号不存在，请重新输入")
			delete_student()

def update_student():
	'''修改学员'''
	global info
	no = int(input("请输入要修改的学生学号："))
	for item in info:
		if item["no"] == no:
			greed = input("请输入要修改的年纪：")
			item["greed"] = greed
			break
		else:
			print("输入的学号不存在，请重新输入！")
			update_student()
	print(info)

def select_no():
	'''查询学员'''
	global info
	no = int(input("请输入要查询的学生学号："))
	for item in info:
		if item["no"] == no:
			print("学生学号：{0}，学生姓名；{1}，学生年龄：{2}，学生性别：{3}，学生年纪：{4}".format(item["no"],item["name"],item["age"],item["sex"],item["greed"]))
			break
		else:
			print("输入的学生学号不存在，请重新输入！")
			select_no()

def select_all():
	print("学号", "\t", "姓名", "\t", "年龄", "\t", "性别", "\t", "年纪")
	for item in info:
		print(item["no"], "\t", item["name"], "\t", item["age"], "\t", item["sex"], "\t", item["greed"])

def info_main():
	while True:
		main()
		num = int(input("请输入序号："))
		if num == 1:
			add_student()
		elif num == 2:
			delete_student()
		elif num == 3:
			update_student()
		elif num == 4:
			select_no()
		elif num == 5:
			select_all()
		elif num == 6:
			exit(0)
		else:
			print("输入的数字错误！")

if __name__ == '__main__':
    info_main()